home *** CD-ROM | disk | FTP | other *** search
- /*
- File: UnitTableDeviceAccess.h
-
- Contains: Required exported functions for Device Access Modules
-
- Version: 1.0
-
- Copyright: © 1999-2000 by Apple Computer, Inc., all rights reserved.
-
- */
-
- #pragma once
-
- #include <MacTypes.h>
- #include <NameRegistry.h>
- #include <Devices.h>
- #include <DriverGestalt.h>
-
- #include "StorageClassPublicAPI.h"
-
- // Errors reported by Device Access Module
- enum
- {
- kDeviceAccessRequestPending = 1, // The request from the UTM is still be processed
- kDeviceAccessNoMediaError = -5000, // There is currently no media in the drive
- kDeviceAccessMediaUnusable, // The media can not be used by this driver, request that it be ejected
- kDeviceAccessNotAvailable, // The device cannot currently be accessed
- kDeviceAccessDataTransferErrorOccurred, // The data was not transferred - request may be retried
- kDeviceAccessInterfaceCommunicationsError // The request could not be sent to the device - device is not responding or is gone
- };
-
- // ---------------------- Query Functions ------------------------------
- // These functions do not require a callback routine, and always returns
- // the result immediately. These are used to determine state of the
- // DAM or the device and should be set up by the DAM during the initializtion
- // process. These should not cause device access.
- // ---------------------------------------------------------------------
-
- // Returns true if access to the device through the appropiate I/O manager is possible.
- extern Boolean IsDeviceAccessEnabled( void );
-
- // GetDriverGestaltIntfForInterface - returns the OSType for the interface
- // supported by the DAM. The interface types are defined in DriverGestalt.h
- extern OSType GetDriverGestaltIntfForInterface( void );
-
- // GetDeviceReferenceNumber - returns a UInt32 that holds the device reference
- // number for this device. This number is interpretted differently depending
- // on the 'intf' value and the interpretation is defined in DriverGestalt.h
- extern UInt32 GetDeviceReferenceNumber( void );
-
- // GetDeviceInfoPtr - returns a pointer to the Device Info structure.
- // The Device Info structure is defined in DriverGesalt.h
- extern DriverGestaltDeviceModelInfoResponse *GetDeviceInfoPtr( void );
-
- // GetDriverVersionNumber - returns the version number for this driver.
- // The Device Info structure is defined in DriverGesalt.h
- extern void GetDriverVersionNumber( NumVersion *theVersion );
-
- // GetInterfaceNameString - returns a pascal string of the name of
- // the interface supported by the DAM. Used for the driver's "where" string.
- extern StringPtr GetDeviceWhereString( void );
-
- // GetSupportedMediaTypesPtr - returns a pointer to the supported media structure.
- // The Supported Media Types structure is defined in DriverGesalt.h
- typedef struct SupportedMediaStruct
- {
- UInt32 supportTypesCount; /* The number of Media Types in the array */
- OSType supportedTypesArray[4]; /* Array of supported media types */
- } SupportedMediaStruct;
-
- extern DriverGestaltSupportedMediaTypesResponse *GetSupportedMediaTypesPtr( void );
-
- // This query function is used to determine if this interface should be allowed
- // to be used for Virtual Memory page mapping. If the DAM returns false, the
- // driver not allow any VM usage on the attached device. If the returned value
- // is true, the UnitTable module will determine what VM options should be allowed
- // based on the device type, media type and write protect status.
- extern Boolean DoesInterfaceHaveVirtualMemoryCapabilities( void );
-
- // Query function for getting the MediaProperties
- // This function will return information about the media currently in the device.
- extern void GetMediaProperties ( UInt32 *TotalBlocksOnMedia, UInt32 *BlockLengthInBytes, Boolean *IsWriteProtected, OSType *currentType );
-
- // ---------------------- Action Functions -----------------------------
- // Each of these functions require a callback procedure pointer and will
- // be performed asynchronously
- // ---------------------------------------------------------------------
- // The default completion routine pointer. All completion routines must contain
- // at least these two return parameters. If the completion routine does not need
- // to return any other data, it should be of this type, else an extension of this type.
- typedef CALLBACK_API_C ( void, DefaultDAMCompletionProcPtr ) (
- UInt32 userData,
- OSStatus status );
-
- // Initialize routine - called to enable access to the device and interface.
- // Must be called before the driver can access the device.
- // This routine may allocate memory so it must be called at task time
- typedef DefaultDAMCompletionProcPtr InitializeCompletionProcPtr;
- extern OSStatus InitializeDeviceAccess( DriverRefNum theRefNum, RegEntryIDPtr theRegEntryPtr );
-
- // Terminate routine - called to terminate access to the device or interface.
- // Must be called when the driver is closed to free up resources used by the Device Access Module.
- // This routine may deallocate memory so it must be called at task time.
- typedef DefaultDAMCompletionProcPtr TerminateCompletionProcPtr;
- extern OSStatus TerminateDeviceAccess( DriverRefNum theRefNum, RegEntryIDPtr theRegEntryPtr );
-
- // Control and Status entry points. Any control or status call that is not handled by the UnitTable
- // Module will be sent to the Device Access Module since the call may be interface specific or, when
- // sopported, may be for a Device Specific Module.
- typedef DefaultDAMCompletionProcPtr ControlStatusCompletionProcPtr;
- extern OSStatus HandleControlRequest ( UInt32 userData,
- CntrlParamPtr cntrlPBPtr,
- ControlStatusCompletionProcPtr callBack );
-
- extern OSStatus HandleStatusRequest ( UInt32 userData,
- CntrlParamPtr cntrlPBPtr,
- ControlStatusCompletionProcPtr callBack );
-
- // Check for media entry point. When the DAM calls the completion routine for this request when
- // media was detected, the DAM will have already determined everything it needs to know about the
- // media. These include things like media capacity, if the media is write protected and the type
- // of media that was detected.
- typedef DefaultDAMCompletionProcPtr CheckIfMediaIsPresentCompletionProcPtr;
- extern OSStatus CheckIfMediaIsPresent( UInt32 userData, CheckIfMediaIsPresentCompletionProcPtr callBack );
-
- // Lock Media entry point
- // Locks the media. If a user presses the eject button the media will not be ejected.
- typedef DefaultDAMCompletionProcPtr LockMediaCompletionProcPtr;
- extern OSStatus PreventMediaRemoval( UInt32 userData, LockMediaCompletionProcPtr callBack );
-
- // Unlock Media entry point
- // Unlocks the media. If a user presses the eject button the media will be ejected.
- typedef DefaultDAMCompletionProcPtr UnlockMediaCompletionProcPtr;
- extern OSStatus AllowMediaRemoval( UInt32 userData, UnlockMediaCompletionProcPtr callBack );
-
- // Eject Cartridge entry point
- typedef DefaultDAMCompletionProcPtr EjectCartridgeCompletionProcPtr;
- extern OSStatus EjectCartridge( UInt32 userData, EjectCartridgeCompletionProcPtr callBack );
-
- // Flush Write cache entry point
- // Causes the device to write any cached data to the media
- typedef DefaultDAMCompletionProcPtr FlushCacheCompletionProcPtr;
- extern OSStatus FlushDriveWriteCache( UInt32 userData, FlushCacheCompletionProcPtr callBack );
-
- // Read/Write a single buffer entry point
- typedef DefaultDAMCompletionProcPtr RWBlocksCompletionProcPtr;
- extern OSStatus ReadWriteSingleBuffer( UInt32 userData, UInt32 startBlock, UInt32 blockCount, Ptr buffer,
- UInt32 byteCount, Boolean doWrite, RWBlocksCompletionProcPtr callBack );
-
- // Read/Write a scatter-gather list entry point
- struct SGElement {
- Ptr SGAddr;
- UInt32 SGCount;
- };
- typedef struct SGElement SGElement, *SGElementPtr;
-
- struct SGList
- {
- UInt32 sgNumberElements;
- SGElementPtr sgElementList;
- };
-
- typedef struct SGList SGList, *SGListPtr;
-
- typedef DefaultDAMCompletionProcPtr RWScatterGatherCompletionProcPtr;
- extern OSStatus ReadWriteScatterGatherList( UInt32 userData, UInt32 startBlock, UInt32 blockCount, SGListPtr sgList,
- UInt32 byteCount, Boolean doWrite, RWScatterGatherCompletionProcPtr callBack );
-
- // Format the Media entry point. When the completion routine is called, the DAM will have already determined if the format was
- // successful, and will get the new capacity of the media.
- typedef DefaultDAMCompletionProcPtr FormatMediaCompletionProcPtr;
- extern OSStatus FormatMedia( UInt32 userData, UInt32 FormatCapacity, UInt16 blockSize, FormatMediaCompletionProcPtr callBack );
-